<template>
  <div>
    <h4>count的值为：{{ $store.state.count }}</h4>
    <button @click="handleAdd">+1</button>
    <button @click="handleAddN">+N</button>
    <button @click="handleAddAsync">+1 Async</button>
    <button @click="handleAddNAsync">+N Async</button>
  </div>
</template>
<script>
export default {
  name: 'Add',
  data() {
    return {}
  },
  methods: {
    handleAdd() {
      this.$store.commit('add')
    },
    handleAddN() {
      // todo commit的作用是调用某个mutations函数
      this.$store.commit('addN', 2)
    },
    // todo 异步自增
    handleAddAsync() {
      this.$store.dispatch('addAsync')
    },
    handleAddNAsync() {
      this.$store.dispatch('addNAsync', 5)
    },
  },
}
</script>
<style lang="" scoped></style>
